package com.xuecheng.learning.interfaces.web;

import com.xuecheng.learning.application.service.XcLearnApplication;
import com.xuecheng.learning.domain.model.vo.resp.XcChooseCourseResp;
import com.xuecheng.learning.infrastructure.util.SecurityUtil;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author itcast
 */
@Slf4j
@RestController
public class XcChooseCourseApi {

    @Autowired
    private XcLearnApplication xcLearnApplication;

    @ApiOperation("添加选课")
    @PostMapping("/choosecourse/{courseId}")
    public XcChooseCourseResp chooseCourse(@PathVariable("courseId") Long courseId){
        Long userId = SecurityUtil.getUser().getId();

        return xcLearnApplication.chooseCourse(userId, courseId);
    }
}
